package org.thomias.loggertest;

import java.util.Enumeration;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler;

public class Main {
	private static Logger logger = Logger.getLogger("kiki.keke");

	public static void main(String argv[]) {
		// Handler fh = new FileHandler("%t/wombat.log");/
		Handler fh = new StreamHandler(System.out, new SimpleFormatter());
		fh.setLevel(Level.ALL);
		Logger.getLogger("").addHandler(fh);
		Logger.getLogger("kiki.keke").setLevel(Level.FINEST);
		LogManager m = LogManager.getLogManager();
		for (Enumeration<String> e = m.getLoggerNames(); e.hasMoreElements();) {
			System.out.println("name=" + e.nextElement());
		}

		// Log a FINE tracing message
		logger.severe("doing stuff");
		logger.warning("doing stuff");
		logger.info("doing stuff");
		logger.fine("doing stuff");
		logger.finer("doing stuff");
		logger.finest("doing stuff");
		System.out.println("parentLevel=" + logger.getParent().getLevel());
		System.out.println("level=" + logger.getLevel());
		fh.flush();
		try {
			Wombat.sneeze();
		} catch (Exception ex) {
			// Log the exception
			logger.log(Level.WARNING, "trouble sneezing", ex);
		}
		logger.fine("done");
		fh.flush();
	}
}
